package model

import (
	"gopkg.in/mgo.v2"
	"time"
)

var mongoSession *mgo.Session
var DB string

func init()  {
	MongoDBHosts := "127.0.0.1:27017"
	DB = "test"
	//AuthUserName := "guest"
	//AuthPassword := "welcome"


	mongoInfo := &mgo.DialInfo{
		Addrs : []string{MongoDBHosts},
		Timeout:  60 * time.Second,
		Database: DB,
		//Username: AuthUserName,
		//Password: AuthPassword,
	}
	var err error

	mongoSession,err = mgo.DialWithInfo(mongoInfo)
	if err != nil {
		panic("mongn init error")
	}
	mongoSession.SetMode(mgo.Monotonic, true)
}

